package com.bilifuture.statemachine.machine;


import com.bilifuture.statemachine.interceptor.StateMachineInterceptor;
import com.bilifuture.statemachine.message.Message;
import com.bilifuture.statemachine.message.Response;
import com.bilifuture.statemachine.transition.Transition;

import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author bilifuture
 * @description: 状态机
 * @date 2022-02-23
 */
public class StateMachineConfig {
    
    /**
     * 状态机name
     */
    private String name;
    
    /**
     * 状态机描述
     */
    private String desc;
    
    /**
     * 状态机中的所有转换
     */
    private Set<Transition> transitionSet;
    
    /**
     * 缓存事件与状态机transination的对应关系
     */
    private Map<String,Transition> cache = new ConcurrentHashMap<>();
    
    /**
     * 拦截列表,本状态机独享
     */
    private List<StateMachineInterceptor> interceptorList;
    
    
    public void setName(String name) {
        this.name = name;
    }
    
    public String getDesc() {
        return desc;
    }
    
    public void setDesc(String desc) {
        this.desc = desc;
    }
    
    public Set<Transition> getTransitionSet() {
        return transitionSet;
    }
    
    public void setTransitionSet(Set<Transition> transitionSet) {
        this.transitionSet = transitionSet;
    }
    
    public Map<String, Transition> getCache() {
        return cache;
    }
    
    public void setCache(Map<String, Transition> cache) {
        this.cache = cache;
    }
    
    public void setInterceptorList(List<StateMachineInterceptor> interceptorList) {
        this.interceptorList = interceptorList;
    }
    
    /**
     * 获取状态机名称
     *
     * @return {@link String}
     */
    public String getName() {
        return null;
    }
    
    /**
     * 获取该状态机中的所有转换过程
     *
     * @return {@link Set}<{@link Transition}>
     */
    public Set<Transition> getTransitions() {
        return null;
    }
    
    /**
     * 根据事件触发状态机
     *
     * @param event 事件
     * @return {@link Response}
     */
    public Response trigger(String event) {
        return null;
    }
    
    /**
     * 根据事件 + 消息数据 触发状态机
     *
     * @param event   事件
     * @param message 消息
     * @return {@link Response}
     */
    public Response trigger(String event, Message message) {
        return null;
    }
    
    public List<StateMachineInterceptor> getInterceptorList() {
        return interceptorList;
    }
}
